home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
workbench
/
dir
/
dum2
/
dumod2.doc
< prev
Wrap
Text File
|
1987-05-28
|
18KB
|
344 lines
TDI Modula-2 Directory Utility v1.5 - By Greg Browne
(reached through New Horizons BBS-PC at 505-437-9117 after 7:00 p.m. MST)
( or Las Cruces RCP/M at 505-524-8372 any time )
Why write another Directory Utility with all the available 'c' code versions?
Have you ever tried to read your M2: directory with them? They only allow
100 files in a directory. I have over 230 in my M2: directory, and they just
pretend the ones over 100 aren't there. So...this allows 300 as written.
It can be expanded or shrunk easily by recompiling DuDir.def/.mod with a
different MaxMax.
This is my first larger project in Modula-2. I am sure there are many things
I could have done more sleekly and professionally. If someone hacks this up
and makes it better, all I ask is that they put their efforts up on some
boards for others to study. THERE IS VERY LITTLE STUDY MATERIAL FOR MODULA-2
ON THE AMIGA. It could be remedied if everyone shared their discoveries.
ALL I ASK IS THAT YOU LEAVE THIS DOCUMENT (ALTERED THOUGH IT MAY BE) WITH
THE PROGRAM, AND THAT YOU PUT ADEQUATE COMMENTS INTO THE SOURCE CODE SO
SOMEONE CAN FIGURE OUT WHAT YOU DID. (EVEN IF I DIDN'T)
Thanks to Richie Bielack (who doesn't know me) for the gadget ideas and the
WBStartup code example, and to all the zillions of 'c' programmers for the
general DU structure ideas. Also to Les Caudle at TDI, who was very patient
with me on the phone several times.
BUG: I seem to have missed something, and I can't find ANYTHING to cause
it, but twice (out of hundreds of runs) it has just gone away.
NOT guru, just freeze in place. If you find it, tell me where. I know
it isn't stack problem, because mostly it runs great even with a
4000 stack. (The big array for filenames is AllocMem'ed).
DISCLAIMER: I take no responsibility for damage or lost files if someone
is foolish enough to use this on valuable files untested.
I am NOT a professional programmer, and am prone to as many
mistakes as anyone else.
PERSONAL: This program is specifically placed in the public domain. Take
FOIBLES this code and use it, delete it, hack it, give it away, copy
it or whatever. Just don't try to sell it. (I doubt that it is
worth much anyway). Please, please, don't have the gaul to take
p.d. software, alter it, and call it 'shareware' just because you
add a nice feature to it. (It will probably Guru on the user and
cause them to hate you). I dislike seeing 'shareware' on so many
programs "just in case" the program proves to be useful. Shareware
used to be reserved for significant 'programs' (not utilities), but
it is so misused lately that it is no wonder so many people don't
honor it. Don't get me wrong, some programs are worth paying for.
If someone needs 'incentive' to continue developing programs, then
they should go into it for a serious living. Otherwise, do it for
the love of it or don't do it. (This will probably make me some
kind of villain to some of you, but I'll survive.)
(* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *)
OPERATION NOTES
Please realize that everything in this program is "relative verify". That
means you have to press AND RELEASE the left mouse button over a gadget
(or name) for it to register with the program. You can sometimes save some
grief by moving the pointer off a gadget without releasing the mouse button,
and then releasing it in some blank area.
ALSO if you are doing some multiple-file item like COPYDEL or ZAPFILE, you
may interrupt it by pressing the mouse button on something. It will halt
after the current operation is complete. (COPYDEL Includes deleting the
source file it is copying as part of the same operation - sorry!)
(*-----------------------------------------------------------------------*)
The screen has 5 major divisions.
1) The large 'window' is the file display area. It is where files are
shown for selected directories. (It is a gadget, by the way)
2) Immediately above this window is a series of device selection gadgets.
These are "one-click-direct-select" gadgets.
3) To the right of the window is a slider. This allows scrolling through
lists of filenames which are too long to show in a (15 name) window.
4) To the right of the slider are the 'BUTTON GADGETS'. They are the
click-select functions. Some are used alone, others in conjunction
with the other areas as will be described.
5) Below the 'GADGETS' are the string display areas, marked R,S,D, and M.
These are for typed input and messages back to you.
DEVICE SELECTION GADGETS: -> df0: df1: df2: dh0: dh1: ram: vd0:
Clicking the left mouse button on any of these will cause the selection
of this device. It will be read and the files displayed in the filewindow.
FILEWINDOW GADGET:
Clicking on top of an 'unselected' filename (white on black) causes it to
be 'selected' and means it will be included in several multiple-file
operations which are described below.
Clicking on a 'selected' filename (black on white) will 'unselect' it.
Clicking on a directory name (orange on black) will cause it to be
'selected'. A prompt will appear in the message field (M) and give you
the option of switching into that directory with a second click on top
of it. (Clicking anywhere else will cancel this option).
Clicking on a selected (but entry cancelled) directory will 'unselect' it.
Note that a click to cancel is not acted on except as a cancel.
NOTE That only one directory at a time may be 'selected'.
Any and/or all filenames may be 'selected'.
SLIDER GADGET:
The slider is a convenient way of scrolling through a long list of
filenames for review. (This Du handles 300 names as currently written).
Clicking below the white portion of the slider (in the background area)
will advance a 'page' of names. You can also click-hold on the slider and
move it wherever you wish. If the slider is filled and will not move,
then all files/directories are displayed.
STRING INPUT/OUTPUT GADGETS: -> Marked R S D M
The 'R' gadget is the Run gadget. It is primarily to hold arguments to
pass to a program being run, as though they were a command line tail.
This gadget may occasionally be only part of a command line tail as will
be described below. YOU MAY CLICK-AND-ENTER IN THIS GADGET.
The 'S' gadget is the Source gadget. It displays the name of the currently
displayed directory or device. If you click a device gadget, the name
will be placed here. IF YOU CLICK-AND-ENTER into this gadget, the name
you enter will be taken as a new device or directory to access. If access
to the entered name fails, the program will return to the last accessed
directory (or to ram: if that fails).
The 'D' gadget is the Destination gadget. It holds the name of the path
(or filename in some cases) to be used for certain GADGET functions such
as COPY, MOVE, RENAME, ETC. YOU MAY CLICK-AND-ENTER IN THIS GADGET.
The 'M' gadget is the Message gadget. It will display messages and other
information from time to time. IF YOU CLICK-AND-ENTER IN THIS GADGET,
I WON'T BE RESPONSIBLE. It is supposed to be a one-way (to the user)
communication channel. (I don't think it hurts, but it will ignore you.)
BUTTON GADGETS: (alphabetically - almost) (room for some more - hint hint)
ARC This gadget requires the most complicated selections.
When selected, the program will try to execute 'arc' with the
tail consisting of the R gadget, the D gadget and the filewindow
selected files in that order.
i.e. R -> a
D -> df1:Some.arc
files selected in window -> Joe.doc Bill.exe
Result executed is -> arc a df1:Some.arc Joe.doc
arc a df1:Some.arc Bill.exe
(The selections are concatenated in R - D - files order.)
(One pass made for each file selected - sorry, no multiple tails)
The same result can be achieved faster by this (one 'arc' load):
R -> a df1:Some.arc Joe.doc Bill.exe
D -> [empty]
files selected in window -> [none]
To Arc v something.arc make sure the D gadget is empty and
select the file(s) to be listed. Also works for arc t.
If no filename is selected, it will attempt to run the
arc program with the R [and D if not empty] gadgets only.
This gadget is versatile, and requires some experimentation on
your part to learn just how much it can (and can't) do.
BYTES This will total and display the number of bytes and files for
all 'selected' files in the current filewindow.
CLEAR This is a mass clearing of all (if any) 'selected' files.
SELECT This is the reverse. It 'selects' all files (some Du's name ALL).
COPY This will copy the 'selected' file(s) to the location given in the
D gadget. THIS MUST NOT BE A FILENAME. The path in D must be to
a valid device or directory. Since multiple copying may be done,
copying to a specific filename is not supported.
COPYDEL THIS IS A PHYSICAL COPY WITH DELETE AFTER. This is identical in
operation to COPY **EXCEPT** the original file is deleted if
the copy operation is successful. (I got tired of reselecting
and deleting the old copies).
DELDIR This is the command to delete a directory (which must be 'selected'
and empty). IF these conditions are met, the magic CONFIRM will
appear to give you one last chance to back out. Clicking on the
DELDIR gadget again will perform the deletion. Remember that the
first click after highlighting a directory is read ONLY as the
'enter-the-directory-or-not' answer. You will have an extra
click somewhere in this one.
EDIT This gadget will cause your editor to be invoked and the 'selected'
filename(s) to be used as command tail. If more than one file is
selected, they will be edited sequentially. If no filenames are
selected, the editor will be run with no file. The name of the
editor can be changed by patching. Use NewZap to find the only
occurrance of 'MEmacs'. Change it to a null terminated string
of your choice. There is space for up to an 8 character name.
This is not RUN, just EXEC'ed to prevent the program from trying
to RUN one and immediately RUN it again for the next one.
EXEC f-R These two will try to execute the result of sticking together
EXEC R-f the R gadget and the 'selected' filename(s)*. The order of
placement depends on which gadget you select. If no files are
selected, EITHER gadget will attempt to execute the R gadget
content by itself. Unlike RUN f-R etc. below, this does not
try to RUN >NIL: the program. It uses the DOS call EXECUTE
like just typing in a command at the > prompt.
* BE WARNED THAT THESE OPTIONS *WILL* INCLUDE ANY HIGHLIGHTED
DIRECTORY NAME IN THE ATTEMPTS TO STICK TOGETHER R+f OR f+R AND
DO IT. (So you could type 'list' in the R gadget and hit a
directory - then EXEC R+f and get a listing without entering
the directory).
My most common use of this is for repeated copy (etc) of the same
thing. Enter the command into R and exec it over and over.
HPRINT These will cause the 'selected' file(s) to be acted on. The 'H'
HTYPE prefixed GADGETS mean Hex output format. If this is a multiple
PRINT file pass, it may be aborted by clicking ANYWHERE in the window.
TYPE The (H)PRINT commands use the PRT: device. This may be patched
to PAR: easily since PRT: occurs only once in the program body.
INFO This will read the InfoBlock for the devices mentioned in S and
D (if not empty) and report free space. Note that the ram:
device always has 0 free space. The report will always be
source first then destination.
MAKEDIR This will attempt to make a new directory named in the D gadget.
If no complete device:path is given, it will be relative to the
path in the current S gadget. If it is made, then the directory
in S will be reread in case it has changed. A check is made
to insure you are not trying to create a directory with an
already existing name.
MOVE This is a quicker form of rename. The path (only - not name) to
move the 'selected' file(s) to should be in the D gadget. This
will attempt to rename them (between directories not devices).
Since no name change is happening, and the files can only drop
out of sight, they are eliminated from the filewindow without
re-reading the S gadget device.
PARENT, These two commands will attempt to 'back-up' either to the
ROOT parent or root directory of the current device. If they
fail (horrors) they return to the current directory.
RELABEL This is a teaser for my next revision. I wanted to put it in,
but got impatient. It will be used to relabel disks. (NOT
a paper label).
RENAME This attempts to rename the first 'selected' file (should be only
one for this) it finds to the name given in the D gadget. Since
it may be still in the same directory, it will re-read the
directory afterwards. Wherever feasable, MOVE is faster.
RUN f-R These two will try to run the result of sticking together the
RUN R-f R gadget and the 'selected' filename(s). The order of placement
depends on which gadget you select. If no files are selected,
EITHER gadget will attempt to RUN the R gadget content by itself,
a handy way to do small chores. This uses the DOS call to Execute
a RUN >NIL: + the selected stuff. It runs sequentially through all
'selected' files, one at a time. BE AWARE that this can grind
your disks to dust, since as soon as RUN is done, it thinks it
is ready to RUN the next one.
SHOW This will attempt to EXEC any program you have named SHOW and pass
it successively the 'selected' filename(s). If no files have been
selected, nothing will happen. Show can be patched to any 8
character (maximum) filename also. It appears only once in the
program body with spaces behind it. Change that one. The other
one is the gadget text. This is NOT RUN >NIL: for precisely the
reason mentioned in the previous description.
ZAPFILE This is the file delete function. It will bring up the magic
CONFIRM message. If you click the ZAPFILE again, any and/or all
files which are currently 'selected' will be deleted. The M
gadget will show the progress, and the deletion may be stopped
by clicking the left mouse button on any gadget (or in the
filewindow).
D -> R S -> D These commands allow quick movement of R S D
D -> S S -> R contents. -> are all one-way and SWAP's
R -> D SWAP S-D are two-way. IF THE S gadget is altered, by this,
R -> S SWAP R-D it will be acted on as though freshly typed in.
SWAP R-S I got tired of so much typing.
CONFIRM This is not a gadget really, but a question which is to save
you from yourself. On the destructive gadgets, you have to
click a second time to confirm what you want to do. Even if
you click there, you can stop the activity by clicking the
left mouse button while it is going on. The program checks
in between every deletion to see if you clicked.
If you have used other DirUtils, all this should be familiar. If not,
make yourself a junk disk (one that doesn't matter what you do to it)
and try it out. It's easy, and given time (and inclination) someone
will probably put the whole C: directory into one of these things and
still leave it in public domain.
COMPILATION NOTES
When you unarc this set of files, notice that DuTypefile.def and
DuTypefile.mod are shortened to DuTypefi (etc). Please be sure
to rename them before compiling, or it will fail.
There are several library modules to compile first. If you choose
to fiddle with this and re-compile it, do it in this order:
modula DuWindow.def
modula DuWindow (* then put in M2: *)
modula DuTypefile.def
modula DuTypefile (* " *)
modula DuDir.def
modula DuDir (* " *)
modula DuMisc.def
modula DuMisc (* " *)
modula DuM2
link DuM2 o (* be sure to optimize since all are $A+ *)
(* and its too large otherwise *)
THEN you must newzap the load file DuM2.
This is because I can't find a way to imbed nonprinting characters
in constants in Modula-2. I did, but it made them spaces. In the
DuTypefile library module is a multi-color string prompt. To make
it work, do a newzap search for PRT: (It is only there once) and
immediately following it is the familiar <CR> next line <SPACE> next
page etc message. Throughout that message all lower case q's must
be zapped to 1BH (esc) and the 2 lower case x's around the blanks must
be zapped to 0DH (cr). Then the last 'end of file' message has two
lower case q's more to zap to 1BH (esc). This is a pain, I know, but
I didn't want to waste space on a routine to do them at runtime.
After this, you are free to name the load file any way you want.